<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <form>
      name <input type="text" name="uname" id="" />
      <hr />
      age <input type="text" name="age" id="" />
      <hr />
      gender <input type="radio" name="gender" />boy
      <input type="radio" name="gender" />girl
    </form>
    <script>
      /*
        document.forms 获取所有的form
      */
      console.log(document.forms);
      // 获取所有的表单元素
      console.log(document.forms[0].elements);
      // 获取所有的单个表单元素
      console.log(document.forms[0].elements[0]);
      // 通过name属性获取表单元素
      console.log(document.forms[0].elements["uname"]);
      console.log(document.forms[0].elements.uname);
    </script>
  </body>
</html>
